package com.ruoyi.fpa.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fpa.domain.FpaBizDefine;
import com.ruoyi.fpa.service.IFpaBizDefineService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 业务功能Controller
 * 
 * @author koradji@163.com
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/fpa/bizDefine")
public class FpaBizDefineController extends BaseController
{
    @Autowired
    private IFpaBizDefineService fpaBizDefineService;

    /**
     * 查询业务功能列表
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:list')")
    @GetMapping("/list")
    public AjaxResult list(FpaBizDefine fpaBizDefine)
    {
        List<FpaBizDefine> list = fpaBizDefineService.selectFpaBizDefineList(fpaBizDefine);
        return success(list);
    }

    /**
     * 导出业务功能列表
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:export')")
    @Log(title = "业务功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FpaBizDefine fpaBizDefine)
    {
        List<FpaBizDefine> list = fpaBizDefineService.selectFpaBizDefineList(fpaBizDefine);
        ExcelUtil<FpaBizDefine> util = new ExcelUtil<FpaBizDefine>(FpaBizDefine.class);
        util.exportExcel(response, list, "业务功能数据");
    }

    /**
     * 获取业务功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(fpaBizDefineService.selectFpaBizDefineById(id));
    }

    /**
     * 新增业务功能
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:add')")
    @Log(title = "业务功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FpaBizDefine fpaBizDefine)
    {
        return toAjax(fpaBizDefineService.insertFpaBizDefine(fpaBizDefine));
    }

    /**
     * 修改业务功能
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:edit')")
    @Log(title = "业务功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FpaBizDefine fpaBizDefine)
    {
        return toAjax(fpaBizDefineService.updateFpaBizDefine(fpaBizDefine));
    }

    /**
     * 删除业务功能
     */
    @PreAuthorize("@ss.hasPermi('fpa:bizDefine:remove')")
    @Log(title = "业务功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(fpaBizDefineService.deleteFpaBizDefineByIds(ids));
    }
}
